<?php
class Engine_Form_Element_Radio extends Engine_Form_Element {

    protected $options = array();

    public function setOptions(array $options) {
        $this->options = $options;
    }

    public function compile() {
        $result = '';
        $options = $this->options;
        if (is_array($options)) {
            foreach ($options as $value => $option) {
                $result .= '<label class="radio">'."\r\n";
                $result .= '<input type="radio" '. $this->renderAttribs() . ' value="' . $value . '" ' . ($value === $this->value ? 'checked' : '') . '>' .  "\r\n";
                $result .= '<span class="metro-radio">' . $option . '</span>';
                $result .= '</label>'."\r\n";
            }
        }
        return $result;
    }

    public function populate($value) {
        $this->setValue($value);
    }
}